package org.example.wx_springboot.common;

import lombok.Data;

//实现增删改查
//定义一个返回合集
@Data
public class Result {
    private static final String SUCCESS_CODE = "200";
    private static final String ERROR_CODE = "-1";
    //    包装后台数据返回三个属性
    private String code;
    private Object data;
    private String msg;//存放错误的信息

    //    返回成功的信息
    public static Result success(){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);//使用SUCCESS_CODE方法
        return result;
    }

    //    返回data信息
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setData(data);
        return result;
    }

    //    返回错误信息
    public static Result error(String msg){
        Result result = new Result();
        result.setCode(ERROR_CODE);
        result.setMsg(msg);
        return result;
    }
}
